package me.hl.enumtest;

import org.junit.Test;

/**
 * Created by haoliang on 2016/6/20.
 */
public class EnumTest {

    @Test
    //枚举类型的遍历
    public void testOrdinal() {
        for (Color color : Color.values()) {
            System.out.println(color + ".ordinal = " + color.ordinal());
        }
    }


    @Test
    public void switchTest() {
        Color color;
        color = Color.BLUE;
        switch (color) {
            case RED:
                System.out.println("red");
                break;
            case BLUE:
                System.out.println("blue");
                break;
            default:
                System.out.println("other");
        }
    }
}
